<template>
	<ve-parse :article="replaceBrackets(article)" class="span-wrap"/>
</template>

<script>
export default {
    props: {
        // 题干内容
        article: {
            type: String
        },
        // 试题类型
        questionType: {
           type: String 
        }
    },
    methods: {
        // 替换题干中的空格，CF（完形填空）题型横线中间带序号
        replaceBrackets (str) {
            let i = 0;
            return str.replace(/（\s*\)|\(\s*）|\(\s*\)|（\s*）/g, () => {
                // 索引
                i++;
                if (this.questionType === 'CF') {
                     return `<input data-index=${i} type="text" class="rep-input" readonly value="${i}"/> `;
                } else {
                    return `<input data-index=${i} type="text" class="rep-input" readonly value=""/> `;
                }
            });
        }
    }
};
</script>

<style lang="less" scoped>
.span-wrap {
    word-wrap: break-word;
}
/deep/.rep-input {
    width: 50px;
    background: rgba(0,0,0,0);
    border-top: none;
    border-left: none;
    border-right: none;
    outline: none;
    border-bottom: 1px solid #000;
    text-align: center;
}
</style>